package com.ymttest.database.sqlwapper.billinputdb;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.biinputdb.SellerLevelHistory;

public class SellerLevelHistoryWrapper {
	
	SqlManager manager;

	public SellerLevelHistoryWrapper() {
		manager = new SqlManager("biinputdb");
	}

	@SuppressWarnings("unchecked")
	public SellerLevelHistory selectByPrimaryKey(Integer id) {

		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
		List<SellerLevelHistory> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.biinputdb.SellerLevelHistoryMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			sellerLevelHistory = result.get(0);
		}

		return sellerLevelHistory;
	}
	
	public Integer insertSelective(SellerLevelHistory sellerLevelHistory) {

		int result = manager
				.insert("com.ymttest.database.mapping.biinputdb.SellerLevelHistoryMapper.insertSelective",
						sellerLevelHistory);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public SellerLevelHistory selectByDDateAndSellerId(String dDate, Long sellerId) {

		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
		
		HashMap<String, Object> map = new HashMap<>();
		
		map.put("dDate", dDate);
		map.put("sellerId", sellerId.intValue());
		
		List<SellerLevelHistory> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.biinputdb.SellerLevelHistoryMapper.selectByDDateAndSellerId",
						map);
		manager.commit();

		if (result.size() > 0) {
			sellerLevelHistory = result.get(0);
		} else
			return null;

		return sellerLevelHistory;
	}
	
	public static void main(String[] args) {
		
		SellerLevelHistoryWrapper test = new SellerLevelHistoryWrapper();
		
//		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
//		
//		sellerLevelHistory.setDDate(YMTDateUtil.getDate());
//		sellerLevelHistory.setSellerID(24635724);
//		sellerLevelHistory.setUpdateTime(YMTDateUtil.getDate());
//		sellerLevelHistory.setUnconfirm_amount(BigDecimal.TEN);
//		
		System.out.println(test.selectByDDateAndSellerId("2020-04-01", 24635724L));
	}
}
